package com.nidu.demo.user;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.user.dto.UserAddCmd;
import com.nidu.demo.user.dto.UserListQry;
import com.nidu.demo.user.dto.UserPageQry;
import com.nidu.demo.user.dto.UserUpdateCmd;
import com.nidu.demo.common.enums.StatusEnum;
import com.nidu.demo.user.api.SysUserService;
import com.nidu.demo.user.dto.*;
import com.nidu.demo.user.executor.command.*;
import com.nidu.demo.user.executor.query.*;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.io.InputStream;
import java.util.Set;

/**
 * 用户服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysUserServiceImpl implements SysUserService {

    private final UserAddCmdExe addCmdExe;
    private final UserUpdateCmdExe updateCmdExe;
    private final UserDeleteCmdExe deleteCmdExe;
    private final UserSingleQryExe singleQryExe;
    private final UserListQryExe listQryExe;
    private final UserPageQryExe pageQryExe;

    @Override
    public SingleResponse<UserCO> add(UserAddCmd cmd) {
        return addCmdExe.execute(cmd);
    }

    @Override
    public SingleResponse<UserCO> update(UserUpdateCmd cmd) {
        return updateCmdExe.execute(cmd);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<UserCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public MultiResponse<UserCO> list(UserListQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public PageResponse<UserCO> page(UserPageQry qry) {
        return pageQryExe.execute(qry);
    }

    @Override
    public Response resetPassword(UserResetPasswordCmd cmd) {
        return updateCmdExe.resetPassword(cmd);
    }

    @Override
    public SingleResponse<UserProfileCO> getProfileById(Long id) {
        return singleQryExe.getProfileById(id);
    }

    @Override
    public Response updatePassword(Long userId, UserUpdatePasswordCmd cmd) {
        return updateCmdExe.updatePassword(userId, cmd);
    }

    @Override
    public Response updateStatus(Long id, StatusEnum status) {
        return updateCmdExe.updateStatus(id, status);
    }

    @Override
    public Response updateProfile(Long userId, UserUpdateProfileCmd cmd) {
        return updateCmdExe.updateProfile(userId, cmd);
    }

    @Override
    public SingleResponse<String> updateAvatar(Long userId, InputStream inputStream) {
        return updateCmdExe.updateAvatar(userId, inputStream);
    }

} 